﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0" />

    <title></title>

    <style>
        * {
            margin: 0px;
            padding: 0px;
        }

        body {
            font-family: Roboto,Helvetica Neue,Helvetica,Tahoma,Arial,Microsoft YaHei,PingFang SC;
            font-size: 14px;
            line-height: 1.28571;
            color: #171a1d;
            background-color: #f0f0f0;
        }


        .main {
            padding: 0px;
            margin: 20px;
            background-color: transparent;
        }

        .title {
            width: 100%;
            /* max-width: 1180px; */
            min-height: 80px;
            position: relative;
            display: flex;
            align-items: center;
            background-image: url('./images/my_ico/title_01.jpg');
            /* background-color: #0079F2; */
            background-repeat: no-repeat;
            background-size: cover;
            background-position: right;
            margin-bottom: 12px;
            border-radius: 8px;
        }

        .title-tname {
            position: absolute;
            width: 40%;
            font-size: 16px;
            line-height: 24px;
            margin: 12px;
            color: #ffffff;
            text-overflow: -o-ellipsis-lastline;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            line-clamp: 2;
            -webkit-box-orient: vertical;
            margin: 16px;
        }


        .my_pro_1 {
            background: #fff;
            overflow: hidden;
            border-radius: 8px;
            margin-top: 10px;
            margin-bottom: 5px;
        }


        .my_pro_11 {
            padding: 20px 24px;
        }

        .my_pro_111 {
            display: flex;
            align-items: center;
            justify-content: space-between;
        }

        .my_pro_111_image {
            background-image: url('./images/my_ico/my01_dw.png_.webp');
            object-fit: cover;
            border-radius: 0px;
            background-position: 0px 0px;
            background-repeat: no-repeat;
            background-size: 48px 48px;
            height: 48px;
            width: 48px;
        }


        .my_pro_112 {
            width: 48px;
            height: 48px;
            object-fit: cover;
            border-radius: 0px;
        }


        .my_pro_11111 {
            font-size: 14px;
            line-height: 22px;
            padding-bottom: 12px;
        }

        .my_pro_11112 {
            font-size: 32px;
            color: #1f3858;
        }




        .pro_1 {
            border-radius: 8px;
            background: #fff;
            overflow: hidden;
            margin-top: 15px;
            margin-bottom: 15px;
        }


        .pro_11 {
            padding-bottom: 12px;
            height: 48px;
            box-sizing: border-box;
            position: relative;
            display: flex;
            line-height: 24px;
            padding: 12px 24px 0;
            background-color: #fff;
        }

        .pro_11_title {
            flex-shrink: 0;
            max-width: 192px;
            color: #171a1d;
            font-size: 16px;
            font-weight: 700;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            line-height: 24px
        }

        .pro_11_line {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            border-bottom: 1px solid #e5e6e8;
        }

        .pro_12 {
            padding: 20px 24px;
        }

        .pro_121 {
            display: flex;
            padding: 8px 0;
            align-items: flex-start;
            justify-content: flex-start;
        }

        .pro_1211 {
            width: 33.3%;
            display: flex;
            flex-direction: column;
            align-items: center;
            justify-content: center;
        }

        .pro_12111 {
            display: flex;
            flex-direction: column;
            align-items: center;
            max-width: 80px;
            cursor: pointer;
        }

        .pro_12111_ico {
            width: 32px;
            height: 32px;
            object-fit: cover;
            border-radius: 0px;
            background-position: 0px 0px;
            background-repeat: no-repeat;
            background-size: 32px 32px;
        }

        .pro_12111_ico_name {
            margin-top: 12px;
            color: #1f3858;
            text-align: center;
            font-family: Roboto,Helvetica Neue,Helvetica,Tahoma,Arial,Microsoft YaHei,PingFang SC;
            font-size: 14px;
            line-height: 1.28571;
        }



        .Subpage {
            font-family: -apple-system-font, "Helvetica Neue", Helvetica, sans-serif;
            font-size: 0.14rem;
            padding: 0.32rem;
            -webkit-box-flex: 1;
            flex: 110%;
        }

        .page-section {
            background: rgb(255, 255, 255);
            margin-bottom: 0.32rem;
        }

        .form-row {
            display: flex;
            -webkit-box-align: center;
            padding: 0px 0.3rem;
            height: 0.88rem;
            align-items: center;
        }

        .form-line {
            height: 1px;
            background-color: rgb(221, 221, 221);
            margin-left: 0.3rem;
        }

        .form-row-label {
            width: 1.8rem;
            font-size: 0.34rem;
            margin-right: 0.1rem;
            text-align: left;
            color: rgb(0, 0, 0);
        }

        .form-row-content {
            -webkit-box-flex: 1;
            flex: 1 1 0%;
            font-size: 0.34rem;
        }





        .form-row2 {
            -webkit-box-align: center;
            /*   padding: 0px 0.3rem; */
            padding: 0px 0px 0px 0.3rem;
            /*          四个参数：
        padding:10px  20px  30px  40px     分别代表：上、右、下、左四个边框的边距值（顺时针方向记就好啦）
        三个参数：
        padding:10px  20px  30px   分别代表：上：10px、    左右各20px、 下：30px
        两个参数：
        padding:10px  20px   分别代表：上下各10px、  左右各20px
        一个参数：
        padding:10px   代表上下左右边距值都是10px */
            align-items: center;
        }

        .form-row2-label2 {
            width: 1.8rem;
            font-size: 0.34rem;
            margin-right: 0.1rem;
            text-align: left;
            color: rgb(0, 0, 0);
            height: 40px;
            line-height: 40px;
        }

        .form-row2-content2 {
            font-size: 0.34rem;
            padding: 0px;
            margin: 0px;
        }




        .input {
            width: 100%;
        }

        .row {
            display: flex;
            align-items: center;
            padding: 0 0.1rem;
        }

        .row-arrow {
            width: 32rpx;
            height: 32rpx;
            margin-left: 16rpx;
        }

        .detail-lable1 {
            padding-left: 0.5rem;
            color: gray;
        }

        .detail-lable2 {
            color: #37bff7;
            position: absolute;
            right: 12%;
        }

        .from-button-detail {
            background-color: white;
            color: #37bff7;
        }

        .form-row-del {
            display: flex;
            -webkit-box-align: center;
            align-items: center;
        }




        .kuma-button {
            padding: 0 32px;
            height: 32px;
            border-width: 1px;
            border-style: solid;
            border-radius: 3px;
            font-size: 12px;
            line-height: 30px;
            box-sizing: border-box;
        }

        .kuma-button-primary {
            background-color: #0089FF;
            border-color: #0089FF;
            color: #fff;
        }

        .kuma-button-secondary {
            background-color: #fff;
            border-color: rgba(31,56,88,.3);
            color: rgba(31,56,88,.6);
        }


        /* 加载动画的样式 */
        #loading {
            display: none; /* 初始时隐藏 */
            position: fixed; /* 固定位置 */
            left: 50%; /* 水平居中 */
            top: 50%; /* 垂直居中 */
            transform: translate(-50%, -50%); /* 精确居中 */
            font-size: 24px; /* 字体大小 */
            color: #fff; /* 文字颜色 */
            background-color: rgba(0, 0, 0, 0.75); /* 背景颜色和透明度 */
            padding: 20px; /* 内边距 */
            border-radius: 10px; /* 圆角 */
        }
    </style>

    <script src="./js/jquery-3.6.0.min.js"></script>







</head>
<body>
    <form id="form1">

        <div id="loading">
            <div class="spinner"></div>
            <div class="spinner_text">
                请稍后，玩命加载数据中......
            </div>
        </div>

        <div id="msg_note">
            <asp:Label ID="Label_note" Text=""></asp:Label>
        </div>

        <div>





            <div class="main">
                <div class="title">
                    <input type="hidden" id="user_id" value="none" runat="server" />
                    <asp:Label ID="Label_title" class="title-tname" Text="" runat="server"></asp:Label>
                </div>
            </div>





            <div class="main">

                <div id="dataContainer">
                </div> <!-- 数据将插入到这里 -->

            </div>









        </div>



    </form>


    <script type="text/javascript">

    $(document).ready(function () {
       loadData();
    });



    async function loadData() {

        // 显示加载动画
        var loadingElement = document.getElementById('loading');
        loadingElement.style.display = 'block';



        var userid = "oTHJ_wu0mFAdMSniwygWWO3164uI";// document.getElementById("user_id").value;//document.getElementById("TextBox_pound_no").value;
        var appid = "LTCE";//document.getElementById("TextBox_wagon_no").value;


        const apiBaseUrl = '/api'; // 修改为后端地址和端口




        const requestData = {
           USERID: userid
           , APPID: appid
           , password: ''
           , username:''
        };

        try {
            const response = await fetch(`${apiBaseUrl}/Index/Post`, {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                },
                body: JSON.stringify(requestData)
            });


            //response.status<400时response.ok true;当response.status>=400 true;
            if (!response.ok) {
                const error = await response.json();
                if (response.status == "401")
                {
                    window.location.href = error.authUrl;
                }
                else
                {
                    var dataContainer = $('#dataContainer');
                    dataContainer.empty(); // 清空现有数据
                    throw new Error(error.message || '查询失败2');
                }

            }
               // 隐藏加载动画
               loadingElement.style.display = 'none';
               var JsonData = await response.json();

                if (JsonData.length === 0) {
                    //首次登录时【到根目录校验，然后在到当前目录，访问导致访问地址/cer_view.aspx，原因暂时未找到】！
                    //window.location.href = './cer_view.aspx';
                    window.location.href = './cer_view.aspx';
                }
                else
                {
                    //加载数据；
                    loadDataToHtml(JsonData);
                }


            } catch (error)
            {
                // 隐藏加载动画
                loadingElement.style.display = 'none';
                // 清空现有数据
                var dataContainer = $('#dataContainer');
                dataContainer.empty();
                showError('错误: ' + error.message);
            }
    }





    function loadDataFromSession() {
        var data = JSON.parse(sessionStorage.getItem('index_data'));
        alert("loadDataFromSession: " + data);
        loadDataToHtml(data);
    }

    function loadDataToHtml(data) {


        $.each(data, function (index, main) {
            let studentsHtml = '';
            $.each(main.items, function (i, item) {
                studentsHtml += `
                                    <div class ="pro_1211"   onclick="window.location.href='${item.link_address}' ">
                                        <div class ="pro_12111" >
                                            <image class ="pro_12111_ico" src="./images/my_ico/${item.menu_icon}" />
                                            <div class ="pro_12111_ico_name">${item.form_name}</div>
                                        </div>
                                    </div>
                            `;
            });

            $("#dataContainer").append(`
                            <div class="pro_1">
                                <div class="pro_11">
                                    <div class ="pro_11_title">${main.class_desc}</div>
                                    <div class="pro_11_line"></div>
                                </div>
                                <div class ="pro_12">
                                    <div class ="pro_121"  >${studentsHtml}</div>
                                </div>
                            </div>
                        `);
        });
    }



    </script>

</body>
</html>